//Thu May 19 05:37:47 CDT 2011
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class FoxIntegerLevelThree {
public:
	long long count(long long min, long long max) {
	}
	long long s(long long n) {
		if (mps[n] > 0)
			return mps[n];
		long long sum = 0;
		while (n > 0) {
			sum += n % 10;
			n /= 10;
		}
	}
	long long d(long long n) {
		long long tmp = n;
		while (n > 10)
			n = s(n);
		return mpd[tmp] = n;
	}

	map<long long, long long> mps;
	map<long long, long long> mpd;
};

